The Scripting app provides access to heartbeat series samples stored in Apple Health using the global API Health.queryHeartbeatSeriesSamples()
. These samples represent beat-to-beat heartbeat intervals collected during workouts or background monitoring sessions (usually via Apple Watch).
Each record contains the time range, number of beats, and optional metadata, but not the raw interval values.
A HealthHeartbeatSeriesSample
object includes:
uuid
: A unique identifier for the samplesampleType
: Always "heartbeatSeries"
startDate
/ endDate
: The time range over which the heartbeats were recordedcount
: The number of heartbeat intervals collectedmetadata
: Optional information attached by the recording source (e.g., watch model, app version)Note: This API provides high-level information about the series. It does not expose individual heartbeat intervals.
Parameter | Description |
---|---|
startDate / endDate |
Optional filter range for sample time interval |
limit |
Maximum number of samples to return |
strictStartDate / strictEndDate |
Whether to include only exact matches |
sortDescriptors |
Optional sorting by startDate or endDate |
requestPermissions |
Optional requesting permission for other types |
Individual heartbeat intervals (R–R data) are not accessible via this API.
To analyze HRV or derive BPM, you’ll need only the count
and duration:
Gaps or anomalies (e.g. pauses, data loss) are not available in this summary sample.
To read heartbeat series:
Health.queryHeartbeatSeriesSamples()
with optional date range or limits.HealthHeartbeatSeriesSample
objects.startDate
, endDate
, count
, and metadata
.count
and duration.This API is useful for overviewing heart rhythm tracking sessions, especially for detecting how often heart rate was sampled during a day or workout.